//
//  Products.swift
//  APPCore
//
//  Created by raymond Peng on 2018/8/7.
//  Copyright © 2018 TanBaYe. All rights reserved.
//

import Foundation
import Domain

struct ProductEntity: Decodable {
    let category: GoodsCategory?
    let goodsdesc: String?
    let goodsdetail: String?
    let hot: Bool = false
    let pics: [GoodsPics]?
    let sort: Int?
    let supercoverpath: String?
    let skus: [GoodsSku]?
    /// 是否显示库存, 如果是 1 则显示, 非 1 则不显示
    let isshow: Int?
    let ids: String?
    let goodsname: String?
}

extension ProductEntity: IProductEntity {
    var productID: String {
        return self.ids ?? ""
    }

    var productName: String {
        return self.goodsname ?? ""
    }

    var productDescription: String {
        return self.goodsdesc ?? ""
    }

    var coverImageURL: String {
        return self.supercoverpath ?? ""
    }

    var index: Int {
        return self.sort ?? -1
    }

    var showStock: Bool {
        return self.isshow == 1
    }
}
